package cn.ffcs.unm.entryDimission.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.stereotype.Repository;

import cn.ffcs.unm.entryDimission.dao.EntryDimissionDao;
import cn.ffcs.unm.entryDimission.model.Entry;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("entryDimissionDao")
public class EntryDimissionDaoImpl extends BaseDaoImpl
		implements
			EntryDimissionDao {

	@Override
	public PageInfo queryInfoByEntry(Entry entry, int currentPage, int pageSize) {
		StringBuilder sb = new StringBuilder();
		sb.append(" select * from  view_HI_PSNJOB where 1 = 1 ");
		List<Object> params = new ArrayList<Object>();
		if (null != entry) {
			if (!StrUtil.isEmpty(entry.getMonthId())) {
				sb.append(" AND monthId = ? ");
				params.add(entry.getMonthId());
			}
			if (!StrUtil.isEmpty(entry.getPkPsndoc())) {
				sb.append(" AND pkPsndoc LIKE ? ");
				params.add("%"
						+ StringEscapeUtils.escapeSql(entry.getPkPsndoc())
						+ "%");
			}
			if (!StrUtil.isEmpty(entry.getClerkcode())) {
				sb.append(" AND clerkcode = ? ");
				params.add(entry.getClerkcode());
			}
		}
		return this.jdbcFindPageInfo(sb.toString(), params, currentPage,
				pageSize, Entry.class);
	}

}
